Repository navigation
fix(metadata): index top-level names so reference resolution no longer scales quadratically - #604
Merged
Merged
Conversation
…lution is linear Reference resolution scanned every top-level object per lookup, so load time grew with the square of the model. Each root now keeps a name index (first match wins, same errors), invalidated when its top-level nodes change, and reused by super resolution and the overlay and merge target scans. Adds per-port count-based regression tests, the scripts/bench-load benchmark, and a CHANGELOG line. No behaviour change: canonical output of a 20x model is byte-identical before and after in all three ports.
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
ResolutionKeyProbeand per-thread rebuild counter (visible only to the Conformance test project viaInternalsVisibleTo) so regression tests count key calls and index rebuilds at 1x/5x/10x rather than wall-clock; TypeScriptpackage/fileDefaultPackagebecame accessors that re-key the node, and the index falls back to the linear scan when a root has a parent/super or overrides child accessors.scripts/bench-load/(model generator, warm-load drivers for all three ports,run.sh, README) and aci-lane-maprule markingscripts/bench-load/*as NONE (run by hand, no test lane); one CHANGELOG line under[Unreleased]/Fixed.Benchmark: 9 warm loads each, median. The machine was busy, so wall-clock is noisy — the deterministic count tests are the regression gate. Python and C# still grow slightly faster than linearly, but a profile shows no remaining hot spot in the lookup.
Validation
Risk Assessment
✅ Low: A semantics-preserving indexing change with correct epoch invalidation on every real mutation path in all three ports, behavior-based regression tests with independent oracles, and both earlier-round fixes verified present in the final tree; no reachable wrong-result or staleness path found.
Testing
Exercised the three ports this change touches, live: the deterministic work-count regression tests (resolutionKey calls per top-level node not growing at 1x/5x/10x, bounded index rebuilds, and never-stale lookups after node add/re-key/merge) passed in TS (63 tests), Python (12) and C# (9), and the real TS and Python loaders loaded a throwaway 20x fitness model with zero errors through the shipped bench drivers, TS producing a valid canonical serialization. Wall-clock medians were captured but treated as noise per the intent; the count tests are the gate and all are green. Baseline broad regression is the configured command's passing run at this commit. No findings.
bun test test/top-level-index.test.ts test/naming-refs.test.ts test/super-resolve.test.ts(63 pass, includes per-node key-call non-growth at 1x/5x/10x and never-stale lookups after add/re-key/merge)…uv run pytest tests/loader/test_top_level_index.py -q(12 passed, covering resolution_key calls per top-level node not growing at 1x/5x/10x, index rebuild bounds, and never-stale after node add/remo…dotnet test MetaObjects.Conformance.Tests --filter "FullyQualifiedName~TopLevelIndex"— Passed! Failed: 0, Passed: 9, Skipped: 0, Total: 9 (592 ms), including ResolutionKey-call non-growth and Rebui…Evidence: TS warm-load of 20x model (real dist loader)
Evidence: Python warm-load of 20x model
Evidence: C# deterministic count tests
Evidence: TS focused index/naming/super-resolve tests
Evidence: Python top-level-index tests
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bun test test/top-level-index.test.ts test/naming-refs.test.ts test/super-resolve.test.ts(63 pass, includes per-node key-call non-growth at 1x/5x/10x and never-stale lookups after add/re-key/merge)…uv run pytest tests/loader/test_top_level_index.py -q(12 passed, covering resolution_key calls per top-level node not growing at 1x/5x/10x, index rebuild bounds, and never-stale after node add/remo…dotnet test MetaObjects.Conformance.Tests --filter "FullyQualifiedName~TopLevelIndex"— Passed! Failed: 0, Passed: 9, Skipped: 0, Total: 9 (592 ms), including ResolutionKey-call non-growth and Rebui…scripts/ci-local.sh --affected --strict-toolchainsBaseline:scripts/ci-local.sh --affected --strict-toolchains(already ran and passed at target commit 70e60e090; not re-run, no source changes made this turn)cd server/typescript/packages/metadata && bun test test/top-level-index.test.ts test/naming-refs.test.ts test/super-resolve.test.tscd server/python && uv run pytest tests/loader/test_top_level_index.py -qcd server/csharp && dotnet test MetaObjects.Conformance.Tests --filter "FullyQualifiedName~TopLevelIndex"Live warm-load:python3 scripts/bench-load/gen-model.py 20 $DEV_SCRATCH/mobench*/model20 && node scripts/bench-load/ts-load.mjs <model> 5 --canonical <out>Live warm-load:python3 scripts/bench-load/py_load.py <model20> 5Teardown:rm -rf /mnt/scratch/mobenchiuyo;git status --porcelainclean✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.